Conversation
…d are needed in ThJobModel.
…s allocations and GC pauses, as well as better interaction with the JIT.
…s), instead it should define getters
Also, I couldn't for the life of me get the unit tests to run. This is what I get:
|
Hrm, seems the tests failed on travis-ci, so maybe these results are bunk (but everything seems to work fine locally for me). If anyone has ideas on why the unit tests don't run locally for me, I'm all ears... |
@fitzgen those results look amazing. Is there an open bug to which I can assign this PR? We have a meta UI performance bug 1067846, and a depends bug 1125229 in case either of those are applicable. I defer to @maurodoglio and @edmorley on the current CI failures. |
@fitzgen I tried your branch locally, it's a big improvement indeed 😃 , thank you! |
item_list = []; | ||
var props = response.data.job_property_names; | ||
var propsLen = props.length; | ||
for (var i = 0, resultsLen = response.data.results.length; i < propsLen; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition to break the loop should be i < resultsLen
I think this is the reason why the tests are failing. You probably don't see the problem if you look at mozilla-central
, since the number of jobs per result set is > 36. On try
you will likely see errors in the console.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before breaking this stuff out into loops (and making the code much less readable), I wonder if we should consider using lodash (https://lodash.com/) instead of underscore. It's supposed to be quite a bit faster than underscore (http://benmccormick.org/2014/11/12/underscore-vs-lodash/), and indeed uses the technique you're using here to iterate through arrays with map (and other things): https://github.com/lodash/lodash/blob/master/lodash.js#L1443
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition to break the loop should be i < resultsLen
I think this is the reason why the tests are failing.
Yes! Thanks! All passing now.
Awesome - thank you for digging into this! |
// creates a new instance of ThJobModel | ||
// using the provided properties | ||
angular.extend(this, data); | ||
if (typeof data === "object" && data !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a comment here to explain why we're not using angular.extend, otherwise someone might be tempted to change it back (since the original form is more concise).
So first off, thanks for doing this! I have some concerns about some of the implementation details, but the basic ideas seem good. Some questions:
As @tojonmz mentioned, we should open a bug to associate this work with. |
This is scrolling to the bottom, start profiling, clicking on "load 50 more", waiting for them all to load, end profiling.
Mostly from ditching underscore to (a) avoid allocations and reduce GC pressure, and (b) get better interaction with the JIT. That's the big FPS gain you can see throughout the middle of the recording. The change to push instead of concat helps ease GC pressure here as well. We could probably ditch the
That would clean up the code organization a little bit so that the properties aren't added in the callback and things are a bit better encapsulated. The jQuery fix causes that initial FPS dip to go from ~300ms down to ~150ms. I talked to @mzgol on twitter, not sure if he filed a bug.
Ok, that worked for me, thanks. FWIW, readthedocs suggests other stuff with |
Ok, so as I feared, the fact that the tests were failing and UI responsiveness improved were related :) We were creating a ton less models because we were only making as many models as there are properties. With the bug fixed, these changes (other than the jQuery one) don't actually help too much. Back to the drawing board! |
@fitzgen do you happen to have a relatively small example that shows the performance penalty of copying event properties in Firefox? I'd like to dive in but I need something to start from and preferably something that is not extremely huge. :) |
Sorry, I don't. I suspect it isn't a bottleneck unless there is a bunch of stuff requiring reflow, so a smaller test case may be hard to create. |
Before
After
That one last FPS dip is completely within angular. I suspect making it go away would involve significant changes within angular, or completely ditching angular in treeherder.